<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* const map1 = new Map();
      const map2 = new Map([
        ["a", 1],
        ["b", 2],
        ["c", 3],
      ]);
      map1.set([1, 2, 3], "aa");
      map2.set("a", "abcd");
      console.log(map1, map2);
      console.log(map2.size);
      console.log(map2.get("a"));
      console.log(map2.has("a"));
      console.log(map2.delete("b"));
      console.log(map2.clear()); */

      // 与数组相互转换
      const mp1 = new Map([
        ["a", 1],
        ["b", 2],
        ["c", 3],
        ["a", 4],
      ]);
      console.log([...mp1]);

      for (const [key, value] of mp1) {
        console.log(key, value);
      }

      mp1.forEach((key, value, mp) => {
        console.log(key, value, mp);
      });
    </script>
  </body>
</html>
